package com.syllabus.servlet;

import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.db.DatabaseHelper;

public class GetSubjectServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/*private static Map<String, String[]> m1 = new LinkedHashMap<String, String[]>(
			0);

	static {
		m1.put("03/CSE", new String[] { "DS", "OOPS", "ADC", "TPDE", "EVS",
				"DPSD" });
		m1.put("04/CSE", new String[] { "DAA", "PQT", "MPC", "OS", "COA",
				"DBMS" });
		m1.put("05/CSE", new String[] { "PP", "DM", "CN", "SE", "SS", "TOC" });
		m1.put("06/CSE",
				new String[] { "AI", "PCD", "OOAD", "WT", "ADT", "ACA" });
		m1.put("07/CSE", new String[] { "MPC", "CNS", "DSP", "DWDM", "CG",
				"EEFA" });
		m1.put("08/CSE", new String[] { "SQA", "HSN" });

	}
	private static Map<String, String[]> m2 = new LinkedHashMap<String, String[]>(
			0);

	static {
		m2.put("03/ECE", new String[] { "DS", "OOPS", "ADC", "TPDE", "EVS",
				"DPSD" });
		m2.put("04/ECE", new String[] { "DAA", "PQT", "MPC", "", "", "" });
		m2.put("05/ECE", new String[] { "", "", "", "", "", "" });
		m2.put("06/ECE", new String[] { "", "", "", "", "", "" });
		m2.put("07/ECE", new String[] { "", "", "", "", "", "" });
		m2.put("08/ECE", new String[] { "", "", "", "", "", "" });

	}*/

	protected void doGet(HttpServletRequest req, HttpServletResponse res)
			throws ServletException, IOException {

		String sem = req.getParameter("sem");
		String dept = req.getParameter("dept");
		res.setContentType("text/plain");
		String respValue = null;
		try {
			respValue = DatabaseHelper.getSubjects(sem, dept.trim()).toString();
		} catch (Exception e) {
			e.printStackTrace();
		}
		res.getWriter().write(respValue.substring(1, respValue.length() - 1));
	}

}
